using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableWorldBossEnemyDao:DaoBase<TableWorldBossEnemy>
    {
        public override void AddPrimaryIndex(TableWorldBossEnemy model)
        {
            cachePrimary[model.EnemyId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableWorldBossEnemy.txt";
        }

        protected override TableWorldBossEnemy ParseRowData(string[] rowData)
        {
            TableWorldBossEnemy data = new TableWorldBossEnemy();
			data.EnemyId = rowData [0];
			data.StrongHoldId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.IsWorldBoss = 0;
            }
            else
            {
                data.IsWorldBoss = int.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.FightScore = 0;
            }
            else
            {
                data.FightScore = int.Parse(rowData[3]);
            }
			data.HeroId = rowData [4];

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.Location = 0;
            }
            else
            {
                data.Location = int.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.Level = 0;
            }
            else
            {
                data.Level = int.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.Attack = 0;
            }
            else
            {
                data.Attack = double.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.PhyDefend = 0;
            }
            else
            {
                data.PhyDefend = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.MagicDefend = 0;
            }
            else
            {
                data.MagicDefend = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.Hp = 0;
            }
            else
            {
                data.Hp = double.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.hit = 0;
            }
            else
            {
                data.hit = double.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.dodge = 0;
            }
            else
            {
                data.dodge = double.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.cri = 0;
            }
            else
            {
                data.cri = double.Parse(rowData[13]);
            }

            if (string.IsNullOrEmpty(rowData[14]))
            {
                data.antiCri = 0;
            }
            else
            {
                data.antiCri = double.Parse(rowData[14]);
            }

            if (string.IsNullOrEmpty(rowData[15]))
            {
                data.criFactor = 0;
            }
            else
            {
                data.criFactor = double.Parse(rowData[15]);
            }

            if (string.IsNullOrEmpty(rowData[16]))
            {
                data.damageAdd = 0;
            }
            else
            {
                data.damageAdd = double.Parse(rowData[16]);
            }

            if (string.IsNullOrEmpty(rowData[17]))
            {
                data.damageReduce = 0;
            }
            else
            {
                data.damageReduce = double.Parse(rowData[17]);
            }
			data.SkillId1 = rowData [18];
			data.SkillId2 = rowData [19];
			data.UltSkillId = rowData [20];

            if (string.IsNullOrEmpty(rowData[21]))
            {
                data.SkillCastChance = 0;
            }
            else
            {
                data.SkillCastChance = double.Parse(rowData[21]);
            }
			data.Talent0 = rowData [22];
			data.Talent1 = rowData [23];
			data.Talent2 = rowData [24];
			data.Talent3 = rowData [25];
			data.Talent4 = rowData [26];
			data.Talent5 = rowData [27];

            return data;
        }


        public override void AddOneIndex(TableWorldBossEnemy model)
        {
            if (!cacheOneIndex.ContainsKey(model.StrongHoldId.ToString()))
            {
                cacheOneIndex[model.StrongHoldId.ToString()] = new List<TableWorldBossEnemy>();
            }
            cacheOneIndex[model.StrongHoldId.ToString()].Add(model);
        }
    

    }

}
